import { createI18n } from 'vue-i18n/index'
import elementEnLocale from 'element-plus/lib/locale/lang/en' // element-ui lang
import elementZhLocale from 'element-plus/lib/locale/lang/zh-cn' // element-ui lang
import 'dayjs/locale/zh-cn'
import cn from './cn'
import en from './en'

const messages = {
  [elementEnLocale.name]: {
    ...en,
    ...elementEnLocale
  },
  [elementZhLocale.name]: {
    ...cn,
    ...elementZhLocale
  }
}
const i18n = createI18n({
  locale: localStorage.getItem('lang') || elementZhLocale.name,
  fallbackLocale: elementZhLocale.name,
  messages
})

export default i18n
